import Vue from 'vue'
import App from './App'
import store from './store/index' // store
import cuCustom from '@/components/colorui/components/cu-custom.vue'
import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue'
import uView from "uview-ui"

Vue.use(uView);
Vue.component('cu-custom', cuCustom)
Vue.component('uni-number-box', uniNumberBox)

Vue.config.productionTip = false
App.mpType = 'app'


// 封装的展示消息提示的方法
uni.$showMsg = function (title = '数据加载失败！', duration = 1500) {
  uni.showToast({
    title,
    duration,
    icon: 'none',
  })
}

//截取文字
Vue.directive('truncate', {
  inserted: function(el, binding) {
    const maxLength = binding.value || 10; // 设置默认的最大截取长度为10个字符
    const text = el.innerText;
    if (text && text.length > maxLength) {
      el.innerText = text.slice(0, maxLength) + '...';
    }
  }
})
//去除文字空格
Vue.directive('trim-space', {
  update: function(el) {
    el.innerText = el.innerText.trim();
  }
})

const app = new Vue({
	...App,
	store
})
//挂载到全局，让所有页面都能接收
app.$mount()
